package org.example.JVM.ASM;

import org.example.JVM.ASM.Visitor.ClassWriter;
import org.example.JVM.ASM.Visitor.FieldVisitor;
import org.example.JVM.ASM.Visitor.MethodVisitor;

/**
 * @description:
 * @author: farprt
 * @create: 2022-11-16 17:02
 **/
public class App {

    public static void main(String[] args) {
        ClassWriter classWriter = new ClassWriter();
        classWriter.visit(52, "public", "org.example.App");
        // 添加字段
        FieldVisitor fieldVisitor = classWriter.visitField("private", "name", "Ljava/lang/String;");
        // 为字段添加注解
        fieldVisitor.visitAnnotation("@Getter", true);
        // 添加方法
        MethodVisitor methodVisitor = classWriter.visitMethod("public", "getName", "(Ljava/lang/String)V");
        // 设置局部变量表和操作数栈大小
        methodVisitor.visitMaxs(1, 1);
        classWriter.showClass();
    }
}